package com.sakura.oj.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.sakura.oj.model.entity.ProblemSubmit;
import com.sakura.oj.model.vo.DailySubmissionStat;
import com.sakura.oj.model.vo.RecentPassVo;
import com.sakura.oj.model.vo.UserLanguageSubmitVo;
import com.sakura.oj.model.vo.UserRankVo;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.time.LocalDate;
import java.util.List;

/**
 * @author Sakura
 * @description 针对表【problem_submit(题目提交表)】的数据库操作Mapper
 * @createDate 2025-03-19 20:27:42
 * @Entity generator.domain.ProblemSubmit
 */
public interface ProblemSubmitMapper extends BaseMapper<ProblemSubmit> {

    List<DailySubmissionStat> selectSubmissionStats(@Param("userId") Long userId, @Param("startDate") LocalDate startDate, @Param("endDate") LocalDate endDate);

    List<UserRankVo> selectSubmissionScore(@Param("pageSize") Long pageSize);

    /**
     * 返回对应的热门题目id
     *
     * @param periodDays 时间
     * @param limit      限制
     * @return 热门题目id
     */
    List<Long> selectHotProblemIds(@Param("periodDays") Long periodDays, @Param("limit") Long limit);

    /**
     * 获取用户提交语言统计
     *
     * @param userId 用户id
     * @return 结果
     */
    @Select("select language, count(*) as submit_count from problem_submit where user_id = #{userId} group by language order by submit_count desc")
    List<UserLanguageSubmitVo> selectLanguageSubmitCounts(@Param("userId") Long userId);

    /**
     * 最近提交的题目
     *
     * @param userId 用户id
     * @return 结果
     */
    List<RecentPassVo> selectRecentlySubmittedList(Long userId);
}




